<?php
class admin_cache{
	static function sys(){
		global $_MODULE, $channel;
		$cache = array();
		$_MODULEs = array();
		$_MODULE_result = ssfdb::fetchAll("select id,pid,name,table_name,appname,admin_php,user_list_php,user_list_last_php,user_content_php,is_showpage from ".TABLEPRE."module where `is_lock`=0");
		foreach($_MODULE_result as $_MODULE){
			$temp  = ssfdb::fetchAll("select eid, ext, type from ".TABLEPRE."extend where id = '{$_MODULE['id']}' order by ordering desc");
			$_MODULE['extend'] = array();
			foreach($temp as $val){
				$_MODULE['extend'][$val['eid']] = $val;
			}
			foreach($_MODULE['extend'] as $key=>$val){
				$_MODULE['extend'][$key]['type'] = $_MODULE['extend'][$key]['type'] == 'checkbox' ? 1 : 0;
			}
			$_MODULEs[$_MODULE['id']] = $_MODULE;
		}
		$cache['module'] = addslashes(serialize($_MODULEs));
		$channel_result = ssfdb::fetchAll("select * from ".TABLEPRE."channel where link=0 order by displayorder ASC");
		$template_list = ssfdb::fetchAll("select * from ".TABLEPRE."channel_template ");
		$channels = array();
		foreach($channel_result as $ch) {
			if ($ch['is_link'] == 0) {
				$channels[$ch['channelid']] = $ch;
				$channels[$ch['channelid']]['domain_skin'] = array();
			} 
		} 
		foreach($template_list as $val){
			if(empty($channels[$val['channelid']])) continue;
			$channels[$val['channelid']]['domain_skin'][] = array(
				'domain' => $val['domain'],
				'skin' => $val['skin']
			);
		}
		$cache['channels'] = addslashes(serialize($channels));
		ssfbase::updateConfig('option', $cache);
		ssfbase::get_object('group')->cache();
		$_MODULE = $_MODULEs;
		$channel = $channels;
	}
}
?>